import {ref} from 'vue'
import {defineStore} from 'pinia'

//主题配置
export const useThemeStore = defineStore('theme', () => {
    const theme = ref({
        isCollapse: false,
        current_theme: 'light',
        themes: [],
    })
    //切换展开状态
    const changeCollapse = () => {
        theme.value.isCollapse = !theme.value.isCollapse
    }
    //主题赋值
    const setThemes = (themes) => {
        // const initTheme = [
        //     {
        //         key: 'light',
        //         className: 'light',
        //         themePrimaryColor: '#fff'
        //     },
        //     {
        //         key: 'dark',
        //         className: 'dark',
        //         themePrimaryColor: '#000'
        //     }
        // ]
        theme.value.themes = themes
    }
    //获取当前主题
    const getCurrentTheme = () => {
        return theme.value.themes.find(item => item.key === theme.value.current_theme)
    }
    //主题切换
    const changeTheme = (key) => {
        theme.value.current_theme = key
    }
    return {theme, changeCollapse, setThemes, changeTheme,getCurrentTheme}
}, {persist: true})
